package com.test38_集合;

import org.junit.Test;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Enumeration;
import java.util.List;

/**
 * Collections工具类
 */
public class Demo09_Collections {

    @Test
    public void test1() {
        List<String> all = new ArrayList<>();
        Collections.addAll(all, "www.yootk.com", "edu.yootk.com", "yootk.ke.qq.com");
        System.out.println("【原始集合】" + all);
        Collections.reverse(all);
        System.out.println("【集合反转】" + all);
        Collections.sort(all);
        System.out.println("【集合排序】" + all);
    }

    /**
     * 枚举输出
     */
    @Test
    public void test2() {
        List<String> all = new ArrayList<>();
        Collections.addAll(all, "www.yootk.com", "edu.yootk.com", "yootk.ke.qq.com");
        Enumeration<String> enu = Collections.enumeration(all);
        while (enu.hasMoreElements()) {
            System.out.println(enu.nextElement());
        }
    }
}
